@extends('layouts.wx')
@section('content')
<style>
.title {
    text-align: center;
    font-size: 34px;
    color: #3cc51f;
    font-weight: 400;
    margin: 0 15%;
}
  
</style>
<!--主体-->
<h3 class="title">付款</h3>
<div class="weui-cells">
  <div class="weui-cell">
    <div class="weui-cell__hd"><img src=""></div>
    <div class="weui-cell__bd">
      <p>订单编号</p>
    </div>
    <div class="weui-cell__ft">{{$order->code}}</div>
  </div>
  <div class="weui-cell">
    <div class="weui-cell__hd"><img src=""></div>
    <div class="weui-cell__bd">
      <p>金额</p>
    </div>
    <div class="weui-cell__ft"><span style="color: red;font-weight: bold;">¥{{$order->amount}}</span></div>
  </div>
</div>
<div style="margin:10px">
  <a href="javascript:;" onclick="pay()" class="weui-btn weui-btn_primary">微信支付</a>
</div>

@endsection
@section('js')
@section('js')
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
wx.config(<?php echo $js->config([
    'chooseWXPay'
  ], false) ?>);
function pay() {
  // $.toast("支付成功", function() {});
  // $('form[name="fm_pay"]')[0].submit();
  wx.chooseWXPay({
      timestamp: <?= $config['timestamp'] ?>,
      nonceStr: '<?= $config['nonceStr'] ?>',
      package: '<?= $config['package'] ?>',
      signType: '<?= $config['signType'] ?>',
      paySign: '<?= $config['paySign'] ?>', // 支付签名
      success: function (res) {
          // 支付成功后的回调函数
          $.toast("支付成功", function() {
              location.href = "{{route('home')}}";
          });
      }
  });
}
</script>
@endsection